package com.qianfeng.openapi.web.master.mapper;

import com.qianfeng.openapi.web.master.pojo.Role;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface RoleMapper {
    int deleteByPrimaryKey(Integer id);

    int insert(Role record);

    int insertSelective(Role record);

    Role selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(Role record);

    int updateByPrimaryKey(Role record);

    @Select("select * from role")
    List<Role> findAll();

    // 根据name查询角色信息
    List<Role> findByName(String name);

    @Select("select menu_id from role_menu where role_id = #{roleId}")
    List<Integer> findRoleMenuId(@Param("roleId") Integer roleId);

    @Delete("delete from role_menu where role_id = #{roleId}")
    void deleteRoleMenuByRoleId(@Param("roleId") Integer roleId);

    // 批量添加关系表信息
    int saveRoleIdAndMenuId(@Param("roleId") Integer roleId, @Param("menuIds") Integer[] menuId);
}